package com.ljm.common.dto;

import com.ljm.common.constants.LogConstants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.RequiredArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;

/**
 * spirngmvc 统一返回结果集
 *
 * @author ming
 */
public class BaseResult {
    /**
     * 200：成功，500：错误
     */
    private String status;
    /**
     * Ajax提示消息
     * message.
     */
    private String message;
    /**
     * 数据
     */
    private Object data;
    /**
     * 重定向URL
     * forwardUrl.
     */
    private String forwardUrl;
    /**
     * 调用链id
     */
    private String traceId;

    public BaseResult(String status, String message, Object data, String forwardUrl) {
        this.status = status;
        this.message = message;
        this.data = data;
        this.forwardUrl = forwardUrl;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getForwardUrl() {
        return forwardUrl;
    }

    public void setForwardUrl(String forwardUrl) {
        this.forwardUrl = forwardUrl;
    }

    public String getTraceId() {
        return StringUtils.isEmpty(this.traceId)?LogConstants.trackIdThreadLocal.get():this.traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }
}
